home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume91 / devices / virtalph / part03 < prev    next >
Encoding:
Internet Message Format  |  1991-05-08  |  34.7 KB

  1. Path: news.larc.nasa.gov!amiga-request
  2. From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  3. Subject: v91i102: virt alpha - virtual device driver, Part03/04
  4. Reply-To: grahamw@cpsc.ucalgary.ca (William Graham)
  5. Newsgroups: comp.sources.amiga
  6. Message-ID: <comp.sources.amiga:v91i102@ab20.larc.nasa.gov>
  7. References: <comp.sources.amiga:v91i100@ab20.larc.nasa.gov>
  8. Date: 08 May 91 00:50:19 GMT
  9. Approved: tadguy@uunet.UU.NET (Tad Guy)
  10. X-Mail-Submissions-To: amiga@uunet.uu.net
  11. X-Post-Discussions-To: comp.sys.amiga.misc
  12.  
  13. Submitted-by: grahamw@cpsc.ucalgary.ca (William Graham)
  14. Posting-number: Volume 91, Issue 102
  15. Archive-name: devices/virt-alpha/part03
  16.  
  17. #!/bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 3 (of 4)."
  24. # Contents:  virt_mine.doc
  25. # Wrapped by tadguy@ab20 on Tue May  7 20:50:17 1991
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f 'virt_mine.doc' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'virt_mine.doc'\"
  29. else
  30. echo shar: Extracting \"'virt_mine.doc'\" \(32366 characters\)
  31. sed "s/^X//" >'virt_mine.doc' <<'END_OF_FILE'
  32. X
  33. X
  34. X;----------------------------------------------------------------------------
  35. XJan 7 91
  36. X
  37. X - we need a skeleton device driver; preferably a RAM drive in ML source
  38. X
  39. Xto consume a file:
  40. X
  41. X    get:
  42. X        name
  43. X        size
  44. X        *sparrwed flags
  45. X        *comments
  46. X        *datestamp
  47. X        actual position on media
  48. X    create:
  49. X        master checksum
  50. X        incremental checksum
  51. X        kind of file (figure this out)
  52. X        should be able to take apart qbak disks (even if not ordered)
  53. X
  54. Xfiles should be consumed relative to their sub-directories.
  55. X
  56. Xonce a file is consumed it appears at the current level of the workspace
  57. Xif an entire media is consumed then that media appears in the workspace
  58. X
  59. Xfrom workbench you can move the file, from cli you can rename it
  60. X
  61. Xif a file has duplicates then the user should somehow be informed about
  62. Xthe duplicates, and where they are.
  63. X
  64. X;----------------------------------------------------------------------------
  65. XJan 7 91
  66. X
  67. Xso for a minimum implementation:
  68. X
  69. X    read a disk, all contents into a fascimile image in the mega database
  70. X
  71. X    present the mega database via a device driver, visible to wb and cli.
  72. X
  73. X    search the mega database for duplicate instances, and make locations
  74. X    visible to user immediately.
  75. X
  76. X;----------------------------------------------------------------------------
  77. X
  78. Xanother way:
  79. X
  80. X    read in a disk, stash contents into mega (assign disk id number)
  81. X    print a list of all duplicates
  82. X    support building of a master image
  83. X    from a master image can do diff for near duplicates
  84. X
  85. X;------------------------------------------------------------------------
  86. X
  87. Xread dir (or media)
  88. X    tell-database-i-am-in-dir-x
  89. X    if any sub-dirs then call self recursively with subdir
  90. Xloop:    read next file, add to database,goto loop till done
  91. X    tell-database-i-am-out-of-dir-x
  92. X    exit
  93. X
  94. Xi-am-in-dir-x
  95. X    add x name to database, remember position
  96. X
  97. Xi-am-out-of-dir
  98. X    set jump of array size in old position as end-of-dir
  99. X
  100. Xadd-to-database
  101. X    array:
  102. X    is file or dir, if dir then marks off certain # of array els
  103. X
  104. X;----------------------------------------------------------------------
  105. X
  106. X - need to be able to flexibly add and remove files from conceptual level
  107. Xof dir.  current file systems, such as those on harddrives probably have
  108. Xa hash table off to a subdir, which then has its own hash table off to its
  109. Xportions.
  110. X
  111. X - we can emulate this by having each dir in an array, linked together by
  112. Xa flexible scheme
  113. X
  114. X - entire database should be checksummable by segment to prevent trashing
  115. Xfrom some outside source
  116. X
  117. X - we could actually "have" dirs on disk, and their contents would be only
  118. X   single files describing that disks normal contents
  119. X
  120. X - then at the top level we'd have media names rather than ordinary dirs?
  121. X
  122. X - a "media" should also be a dir i guess, in that all the subdirs and files
  123. X   in it are given the same media id number.  where the name of the "media"
  124. X   as a dir is the same as the agreed upon id number, and all subdirs and
  125. X   stuff just keep their original names.
  126. X
  127. X - the database should be all in ram at a time however i think? hmmm
  128. X   but it can probably be around 1/2 meg, and more error prone that way...
  129. X
  130. X;-----------------------------------------------------------------------
  131. X
  132. Xok so the scheme is:
  133. X
  134. X    - we assign a media number for the disk we are consuming, that
  135. X      becomes its dir, "consume" then call "create-dir"
  136. X
  137. Xcreate-dir:
  138. X    *doesn't* ask for original media (of course) creates dir in image
  139. Xmove:
  140. Xrename:
  141. X    *doesn't* ask for original media, rather just updates internal image.
  142. X    can move into garbage, may be special command to forget a duplicate.
  143. X
  144. Xread:
  145. Xwrite:
  146. Xedit:
  147. Xdelete:
  148. X    operates on specified media (may ask user to insert disk #x)
  149. X
  150. X
  151. X - theory is that you should be able to do actual work from the virtual
  152. X   enviroment, all normal i/o access to the file works as normal, its just
  153. X   its conceived position that is indirect/deferred.
  154. X
  155. X
  156. Xopen old file
  157. Xopen new file
  158. Xread
  159. Xwrite
  160. Xclose
  161. Xseek
  162. Xwaitchar
  163. Xexamine object
  164. Xexamine next
  165. Xdiskinfo
  166. Xparent
  167. Xdelete object
  168. Xcreate dir
  169. Xlocate object
  170. Xcopy dir
  171. Xfree lock
  172. Xset protect
  173. Xsetcomment
  174. Xrename object
  175. Xinhibit
  176. Xrename disk
  177. X
  178. X;------------------------------------------------------------------------
  179. Xjanuary 16th:
  180. X
  181. X        - accept and handle all dos device packets:
  182. X    DIE
  183. X    OPENRW
  184. X    OPENOLD
  185. X    OPENOLD
  186. X    READ
  187. X    WRITE
  188. X    CLOSE
  189. X    SEEK
  190. X        - do normal stuff, like checking if file is in this dir
  191. X        - pass request onto the real device (with full file path)
  192. X    EXAMINE NEXT
  193. X    EXAMINE OBJECT
  194. X    FREE LOCK
  195. X    LOCATE OBJECT
  196. X    INFO
  197. X    PARENT
  198. X    DELETE OBJECT
  199. X    CREATE DIR
  200. X    COPY DIR
  201. X    SET PROTECT
  202. X    SET COMMENT
  203. X    RENAME OBJECT
  204. X        - talk to my own information (pass request to my info handler)
  205. X    DISK INFO
  206. X        - talk to my own info dir
  207. X    inhibit
  208. X    rename
  209. X    morecache
  210. X    waitchar
  211. X    flush
  212. X    rawmode
  213. X        - dont support
  214. X
  215. X;------------------------------------------------------------------------
  216. X
  217. X
  218. X    There is an indirect level of requests, some requests get passed
  219. Xonto the appropriate media, other requests get intercepted and passed to
  220. Xmy own handler.
  221. X
  222. X    In a sense there are three main segments
  223. X
  224. X        1) the VIR: device which gets all initial requests.
  225. X
  226. X        2) the normal device which is an i/o request destination.
  227. X
  228. X        3) another not-visible "device" of mine which provides
  229. X           the functionality of VIR:
  230. X
  231. X    Part (3) must have the following modular upgradable components
  232. X
  233. X        receive and return the desired info from standard
  234. X        requests, as based on an internal database
  235. X
  236. X        the internal database being structured in such a way
  237. X        as that it is accessible and extensible
  238. X
  239. X        possibly being located on disk for sturdyness
  240. X
  241. X;----------------------------------------------------------------------------
  242. X
  243. X    possible structures for vir: internal database
  244. X
  245. X    CHEAP    - doubly linked list of names, with branches at dirs
  246. X          supplemented by info structure per file
  247. X    IF RAM    - written to disk occasionaly as backup
  248. X        - always loads up as a clean minimal memory whenever possible
  249. X    IF DISK - mockup directory structure
  250. X
  251. X    GOOD    - Linked list of mini-hashed tables using the perfect hash
  252. X        - each hashed reference
  253. X    IF RAM    - each hashed reference points to a chunk of data with all
  254. X          file quals
  255. X    IF DISK - each hash table has an associated file, acts same as above
  256. X
  257. X    General
  258. X        - there are browse commands and create/delete commands mostly
  259. X
  260. X        - all commands get passed to whatever handler, they get
  261. X          back the information they want...
  262. X
  263. X    dirs
  264. X        - each name points to a place, if its a dir then that
  265. X          place is either a sub hash or a new linked list...
  266. X
  267. Xrequired info:
  268. X    link.l    forward
  269. X    name    130 chars
  270. X    size.l
  271. X    protect.b
  272. X    edit date.l
  273. X    master csum.l
  274. X    csums.l        (little csums)
  275. X    comments    (if any)
  276. X
  277. X
  278. X
  279. X    get:
  280. X        name
  281. X        size
  282. X        sparrwed flags
  283. X        comments
  284. X        datestamp
  285. X        actual position on media
  286. X    create:
  287. X        master checksum
  288. X        incremental checksum
  289. X        kind of file (figure this out)
  290. X        should be able to take apart qbak disks (even if not ordered)
  291. X
  292. X
  293. X    - can we use the management implementation scheme already in place
  294. X      in a standard ram drive?
  295. X
  296. X
  297. X
  298. X    - all packet commands act as normal except these ones:
  299. X
  300. X        OPENNEW
  301. X            - is not permitted, return some fail condition
  302. X        OPENRW
  303. X            - 
  304. X        OPENOLD
  305. X        READ
  306. X        WRITE
  307. X        CLOSE
  308. X        SEEK
  309. X            - passes request "verbatim" onto real owner
  310. X              flags the client as reply path
  311. X;---------------------------------------------------------------------------
  312. X
  313. Xdear matt
  314. X    here is a case where you're actually releasing something to the
  315. X    public domain is going to come back and help you in turn.  I
  316. X    wish that I were so lucky! (if I could keep my stuff from being
  317. X    censored!).
  318. X
  319. X    - lattice requires a -V on this
  320. X    - Note that we can use "handler" which is supposedly better.
  321. X
  322. X    - Minimally modify the device driver
  323. X    - Submit modified device to Matt Dillion for checking if bug free
  324. X
  325. X    - Allow all file management to still function
  326. X    - Remove OpenNew
  327. X    - Add "real owner" field to ram file node
  328. X    - Read/Write requests get passed to real owner device
  329. X    - force all files to have a very small size (preferably 0)
  330. X
  331. X    - add these functions
  332. X        - reload vir: (from disk database)
  333. X        - unload vir: (to disk database)
  334. X        - coalesce:   (search and merge duplicate files)
  335. X        - toolbox space
  336. X
  337. X;----------------------------------------------------------------------------
  338. X
  339. X    - write a "learn" function
  340. X        acquire media references onto virtual device
  341. X        (have media reference)
  342. X        imbed an "info" function into this learn
  343. X        vir: to vir: should acquire others special junk
  344. X        talks to a special vir: packet
  345. X
  346. X    - pass requests onto device (named reference?)
  347. X        - either must have internal "positive id"
  348. X        - 
  349. X
  350. X;--------------------------------------------------------------------------
  351. X
  352. X    - LEARN is just a COPY which writes a special packet type to host
  353. X      - build up info about next file, export to vir:
  354. X      - do directories etc.
  355. X
  356. X    - open new, as called by learner writes a special header to file,
  357. X      and thats all
  358. X
  359. X    - open old automatically checks if header is mine, if mine then
  360. X      patches request onto real destination.
  361. X
  362. X    - each of my format files has its full path name imbedded in itself
  363. X
  364. X    - how do we refer to the specific device? get source for a copy
  365. X      command (such as arp copy etc).
  366. X
  367. Xtypically
  368. X
  369. X    - a user issues a dos specific command
  370. X    - whatever utility passes the path along to DOS
  371. X    - dos parses out the device
  372. X    - dos attempts to access that device, if not present it requests it
  373. X    - the file is accessed
  374. X
  375. Xchanges
  376. X    - i need to supply the positive id of a media type, not merely
  377. X      the name but the internal def'n unique identifier data
  378. X
  379. X    - this may not be possible to issue at a high level?
  380. X      why? how do people discriminate normally? simply by device?
  381. X      so i could just say insert disk in df0?
  382. X
  383. X    - i guess i really have to ask for not merely a named device
  384. X      but a specific handle for a device...
  385. X
  386. X;---------------------------------------------------------------------------
  387. XJanuary 18th 1991
  388. X
  389. XSIMPLE IMPLEMENTATION SET:
  390. X
  391. X    FEATURES:
  392. X        - ACQUISITION -> learning media (quals/csums)
  393. X        - PASS THRU   -> requesting external online/offline media
  394. X        - COALESCING  -> locating duplicates (csums)
  395. X
  396. X    INTERNAL PHYSICAL COMPONENTS:
  397. X        - wild card handling + recursive dir descent
  398. X        - file and directory management
  399. X        - amigados packet handing
  400. X        - handler skeleton
  401. X
  402. X    VISIBLE PHYSICAL COMPONENTS:
  403. X        - learner
  404. X        - coalescer
  405. X        - device driver
  406. X        - (device driver internal data block)
  407. X
  408. X    INTERNAL LOGICAL COMPONENTS:
  409. X        - all I/O commands are pass thru (to real device)
  410. X        - all management commands are managed by moi
  411. X        - the stub which passes off to either of above
  412. X
  413. X    ATTACK:
  414. X        - clean up Matts code into C++ "strands" of functionality
  415. X          (seperate all internal physical components)
  416. X        - First write AQUISITION
  417. X          such that RAM DRIVE can aquire indirect references
  418. X        - Write PASS THRU
  419. X          (possibly at same time) such that RAM DEVICE is now
  420. X          functioning virtually.
  421. X        - Rewrite database such that it is disk resident always
  422. X        - Write COALESCE
  423. X        - Write ARCHIVAL UTILITY
  424. X        - Write TOOLSPACE with CLOCK, POWEROFF, TRASHCAN, SCRIPT-EXE
  425. X
  426. X
  427. X;---------------------------------------------------------------------------
  428. X
  429. XPositive identification of offline media:
  430. X
  431. X    - We can't use a straight numbering scheme, unless we retain the
  432. X      disk positive ID as well (which is feasible)
  433. X
  434. X    - Does each file retain its entire path?  Yes, except perhaps its
  435. X      master media.  The reason being that the file can be moved around
  436. X      the vir: space, but still retains its linkage to its physical
  437. X      existance.  The media positive id could be maintained as a
  438. X      seperate node, always referenced however, by the file.
  439. X
  440. X    - Unless some obvious, simple and efficient scheme can be arranged
  441. X      for storing media positive ids seperately I may as well store
  442. X      it specifically for each file.  This wastes tons of ram, so I'll
  443. X      have to think about it.
  444. X
  445. X    - Agreed upon ID numbers should grow by multiples of 100 just to
  446. X      leave insertion room if required.
  447. X
  448. X    - AmigaDos implements a mechanism to request a positively ID'ed
  449. X      media.  How do I patch into that mechanism? [ I dunno, emulate it! ]
  450. X
  451. X    - What constitutes a positive ID under AmigaDOS (what do I stash).
  452. X
  453. X    - I can emulate the AmigaDOS positive ID scheme if I stash away
  454. X      the media datestamp,checksum,name, then perform my own search
  455. X      for that media.  If I fail to find the media I am looking for
  456. X      I guess I should fail, although there should be an option to
  457. X      force acceptance of generic media's.
  458. X
  459. X    - When my device driver attempts to pass the DOS packet off to the
  460. X      proper device its going to have to search the device list for
  461. X      the positive ID qualities, and then use the general quals (name)
  462. X      to open up that device for packet communications, then pass off
  463. X      the packet to it (i presume).
  464. X
  465. XWhich brings us to another question:
  466. X
  467. X    - I presume I can open a DOS device quite normally and pass off
  468. X      a packet to that device.  But it would be truly grand if I could
  469. X      drop myself out of the process...simply connect my client to
  470. X      their real request and not require my presence at all.
  471. X
  472. X    - I could even support new writes to the VIR: media in this
  473. X      manner, where the destination was that of the current directory
  474. X      (and perhaps the top level was just a RAM disk).
  475. X
  476. XIssues to code:
  477. X
  478. X    - (i should get positive ID info from learner, and stash it away)
  479. X
  480. X    - Attempt to open a DOS device, and drop a packet into it.  As
  481. X      a test I can have all the I/O to VIR: redirect itself in a
  482. X      natural manner to DR1:
  483. X
  484. X    - Assignments do this, how?  -> Probably have a device definition
  485. X      with a message structure also, and that receiving code fragment
  486. X      passes it along very much the way I want too.  [ SB suggests this ]
  487. X
  488. X    - Soooo... our emulation figures out the device name, positively
  489. X      attempts to identify it, (or requests it be brought online)
  490. X      i then find the message port of the device and patch the request
  491. X      through to it - in such a way that it doesn't return to me.
  492. X
  493. X    - PipeHandler imbeds pipe specific commands into a device specific
  494. X      reference, like P:abc/def.  What can I use that for?
  495. X
  496. X;-------------------------------------------------------------------------
  497. XJan 18th 1991
  498. X
  499. X    - It appears that the command "P:abc/def" gets passed in its
  500. X      entirety to the device driver (in Arg2 of the packet).  This
  501. X      actually occurs because the shell is trying to execute that
  502. X      command.  However at some earlier point the appropriate
  503. X      device has been determined, elsewise P: wouldn't have gotten
  504. X      the message...
  505. X
  506. X      [ Pickpacket confirms this...DOS determines the device,
  507. X        nicely enough we get the 'VIR:' header with all files,
  508. X        (sometimes we may be on 'VIR' so it doesn't really help, or matter ]
  509. X
  510. X    - lets see exactly what a "copy" command passes eh?
  511. X
  512. X      [ not enuf (no source path (ARG!!))...but maybe we can hack it ]
  513. X
  514. X;-------------------------------------------------------------------------
  515. XJan 18th 1991
  516. X
  517. Xediting new files on vir:
  518. X    VIR: generates a positive device ID and absolute file position using
  519. X    an internal default, be that your main harddrive, or ram:, vir: will
  520. X    always put the file at the root level, giving a unique numeric name
  521. X    appendum if file names collide (in which case you still refer to the
  522. X    vir: instance by its normal name).  From that point on the file is
  523. X    treated as an ordinary existing file.
  524. X
  525. Xreading (existing) files on vir:
  526. Xediting (existing) files on vir:
  527. X    all requests are passed to the appropriate device, using the
  528. X    positive device id and absolute file position info that vir keeps.
  529. X
  530. Xclosing edited files on vir:
  531. X    when you close a modified file vir: rebuilds that files checksums.
  532. X
  533. Xlearning (file aquisition):
  534. X    there is a "learn" command which acts exactly like "copy" as
  535. X    far as the user can tell.  Internally passes a little bit of
  536. X    extra-info which specifies at the outset the files owner positive id...
  537. X
  538. X    if it is possible the 'copy' command will be detected and changed
  539. X    to a 'learn'.
  540. X
  541. Xhow about copy from vir: to vir:?
  542. X
  543. X;-------------------------
  544. X
  545. Xx to vir: (new) -> either non-permissible or copy to default
  546. Xx to vir:    -> patch request to owner
  547. Xvir: to vir:    -> just copy reference (implicit or explicit?)
  548. Xvir: to x:    -> patch request to owner
  549. Xx: to x:    -> who cares
  550. X
  551. X;--------------------------------------------------------------------------
  552. Xnew-file alternatives:
  553. X
  554. X    1) write to the media of which i am a sub dir of
  555. X       Not acceptable, because it destroys portability
  556. X
  557. X    2) copy to default, a poor but simple solution
  558. X
  559. X    3) copy with heirarchy if possible (so-so)
  560. X    4) copy create heirarchy (so-so)
  561. X    5) disallow (so-so)
  562. X
  563. X    Best not to implement some arbitrary scheme lacking of exposure
  564. X    to mainframe virtual storage system solutions; so simpler is better.
  565. X
  566. X;----------------------------------------
  567. X
  568. Xanyway new file looks like a hassle; just disable for now, figure out later...
  569. X
  570. X
  571. X;----------------------------------------------------------
  572. Xjan 19th 1991
  573. X
  574. X    ok so we're left with the issue of positive media identification
  575. X
  576. X    fib_diskkey is what?  NOT DOCUMENTED... SHIT
  577. X
  578. X    hmmmm....
  579. X
  580. X;----------------------------------------------------------------
  581. X
  582. Xoperating on a positive id
  583. X
  584. X    search device list for that device name
  585. X    if its a physical media type device then also search for positive id
  586. X    get message port of device
  587. X
  588. X    I wonder how DOS does the search? does it forbid etc?
  589. X
  590. X;------------------------------------------
  591. X
  592. Xall i/o gets passed onto named device
  593. X
  594. X
  595. X    pull file id tag:
  596. X        "filepath/file-orig-name"
  597. X        device pointer (has device name, positive id if any, handle)
  598. X
  599. X    open a message port with the device
  600. X        (just LOCK opened one up with us)
  601. X
  602. X;---------------------------------------------
  603. X
  604. Xhandling old stuff
  605. X
  606. X    1) packet request comes in
  607. X    2) if management request then handle as normal
  608. X    3) if i/o request then:
  609. X        - get device name, device positive id
  610. X        - get process identifier port
  611. X        struct MsgPort *pro = DeviceProc("df0:");/* example */
  612. X        - (or fail)
  613. X        - for now reissue the packet and wait, then reply
  614. X        - later pass packet verbatim to port, don't reply
  615. X
  616. X;---------------------------------------------------------------------------
  617. X
  618. X    ACTION_OPENRW:
  619. X    ACTION_OPENOLD:
  620. X    ACTION_OPENNEW:
  621. X        - get pointer to devinfo
  622. X        - get msgport of named device, attach to handle
  623. X        - attach subdir to filename
  624. X        - patch request thru to device
  625. X    ACTION_READ:
  626. X    ACTION_WRITE:
  627. X    ACTION_CLOSE:
  628. X    ACTION_SEEK:
  629. X        - patch request thru to device (use handle messageport)
  630. X    ACTION_DIE:
  631. X    ACTION_EXAMINE_NEXT:
  632. X    ACTION_EXAMINE_OBJECT:
  633. X    ACTION_INFO:
  634. X    ACTION_DISK_INFO:
  635. X    ACTION_PARENT:
  636. X    ACTION_DELETE_OBJECT:
  637. X    ACTION_CREATE_DIR:
  638. X    ACTION_LOCATE_OBJECT:
  639. X    ACTION_COPY_DIR:
  640. X    ACTION_FREE_LOCK:
  641. X    ACTION_SET_PROTECT:
  642. X    ACTION_SET_COMMENT:
  643. X    ACTION_RENAME_OBJECT:
  644. X    ACTION_INHIBIT:
  645. X    ACTION_RENAME_DISK:
  646. X    ACTION_MORECACHE:
  647. X    ACTION_WAIT_CHAR:
  648. X    ACTION_FLUSH:
  649. X    ACTION_RAWMODE:
  650. X        - all act as normal
  651. X
  652. X
  653. X- get pointer to devinfo
  654. X- get msgport of named device, attach to handle
  655. X    must have devinfo available by pointer
  656. X    just call a gumby routine to return this vector
  657. X
  658. X- attach subdir to filename
  659. X    (don't bother for now)
  660. X
  661. X- patch request thru to device
  662. X    
  663. X;--------------------------------------------------------------
  664. X
  665. XThe driver will have 2 modes
  666. X
  667. X1)    RAMDISK Mode
  668. X
  669. X    This is used to "learn" files
  670. X
  671. X    The learn command submits "ordinary" files to save
  672. X    onto vir: thus any destination can be used for learn (ie: RAM:)
  673. X
  674. X    All reads and writes simply operate on the RAMDRIVE as a RAMDRIVE
  675. X
  676. X2)    Virtual Mode
  677. X
  678. X    All reads and writes are patched through to their real owner
  679. X
  680. X    A special check is performed to only accept VIR: type files
  681. X
  682. XCOMMENTS:
  683. X
  684. X    a) VIRTUAL mode is always on as far as the client is concerned,
  685. X       learn triggers into RAMDRIVE mode, and then back out.
  686. X
  687. X    b) There is a special user do-able way to goto RAMDRIVE MODE
  688. X       thus user can share files between different VIR:'s, or make
  689. X       a backup of the VIR: media.
  690. X
  691. X    c) 'learn' is built directly into the DEVICE, issuing a LEARN
  692. X       command "makes" a learn function!
  693. X
  694. X       or the command can be specified as one batch...
  695. X
  696. X       'learn_df0:mymedia_to_vir:myfile'
  697. X
  698. X       if it accepts spaces then thats great!
  699. X
  700. X    d) coalesce simply eliminates the second media reference of a
  701. X       pair which are the same...
  702. X
  703. X;-------------------------
  704. XAMIGADOS TECH REF PAGE 268 !!!!!
  705. X
  706. X    To distinguish disks with the same name
  707. X    AmigaDOS timestamps the volume on creation, then saves
  708. X    timestamp in list structure.
  709. X
  710. X    
  711. X
  712. X    new handler process per instance of df0:, each having
  713. X    own list struct, if not inserted then save-away any
  714. X    active locks + presumably VolDays...
  715. X
  716. X    on reinsert then probably looks for VolDays, reattaches locks
  717. X
  718. X
  719. X
  720. Xlearn
  721. X    - build up dir,path,filename,checksums, type
  722. X      submit file as a packet to specified device
  723. X
  724. X;----------------------------------------------------------------------------
  725. XSunday Jan 20 00:30
  726. X
  727. X    ok so the learn is coded and works fine
  728. X
  729. X    now:
  730. X        device gets incoming "open" request
  731. X
  732. X        1) search devinfo list for named device
  733. X        2) possibly request media insertion
  734. X           (wait around till its inserted or aborted)
  735. X           (perhaps make it so that it won't be let go before step #5)
  736. X        3) make sure that positive id matches
  737. X        4) substitute entire path into lock
  738. X        5) patch request to that device
  739. X
  740. X    - need mode to switch between being ramdisk and being virtual
  741. X        1) ram mode is just normal
  742. X        2) virtual mode patches all read/write requests
  743. X
  744. X    what are the trade offs of storing FIB info directly into
  745. X    RAM FIB struct versus keeping it as a file?
  746. X        - there is no ram fragmentation benefit either way
  747. X          (ie better ram solutions can be figured out for either)
  748. X        - RAM FIB might be faster (marginally)
  749. X        - file format: external modules like learn are simpler
  750. X          (excellent reason -> allows human handling, truckability)
  751. X          (also makes learn useful for non-internal enviroments)
  752. X
  753. X;------------------------------------------------------------------------
  754. XJan 22 91
  755. X
  756. X    ok so now the requests are being patched off to the proper handler
  757. X    but we're encountering a bug which I think goes like this:
  758. X
  759. X    1)    client finds my process ID and submits a LOCK request
  760. X    2)    I patch the packet off to other process ID which returns LOCK
  761. X    3)    client passes LOCK to me for a read
  762. X    4)    I don't understand the lock because it isn't mine; failure.
  763. X
  764. X    to prove if this is in fact the problem; I should patch ALL
  765. X    requests through, and see if I get a READ packet at all.  If I don't
  766. X    then that suggests that the LOCK carries its own PROCESS ID, and that
  767. X    the bug lies elsewhere.  IE the command READ is generic -> but
  768. X    we know thats not true because you must call the desired handler.
  769. X
  770. X    If this is the problem then the solution is like so:
  771. X
  772. X    1)    client finds my process and submits LOCK request (as before)
  773. X    2)    I submit same request to other process ID, and wait for reply.
  774. X    3)    On success I tag on my own info to the LOCK
  775. X    4)    client passes LOCK to me for a read
  776. X    5)    I check to see if my OWN info is appended
  777. X    6)    If so then I patch LOCK onto other process
  778. X
  779. X    So the issue is that the OPEN and READ requests are both going to
  780. X    come to me; and I'll need some conscious bridge to remember if I
  781. X    opened it; and which device I opened it of.
  782. X
  783. X    I think all I need to stash in the LOCK is the actual device process.
  784. X
  785. X    It would be nicer if all the low level AMIGADOS functions extracted
  786. X    process ID from the lock itself, rather than making that a user
  787. X    responsibility.  This is the root of the problem.
  788. X
  789. X    Basically I'm just acting as a DEVICE ARBITRATOR - - - I can think
  790. X    of the process as 2 parts:
  791. X
  792. X    1) Determining destination DEVICE
  793. X    2) Patching *ALL* related requests to that device.
  794. X
  795. X    In my code the process seems a bit cloudy because on the OPEN I
  796. X    do both more or less atomically.  I should seperate these out to
  797. X    make the relationship more clear.  Possibly having a flag which
  798. X    states if this request is to be specially reserved as a patch request.
  799. X
  800. X    So in that case do I really have to wait for an ACK from the OPEN?
  801. X
  802. X    Somehow if I could stash my information directly into the initial
  803. X    LOCK I would be freed of the responsibility of having to intercept
  804. X    and reply to any packets, I could just pass them straight on.
  805. X
  806. X    Of course it is true that the initial packet must also be modified,
  807. X    and anyway there is a solution, and it looks as if things like
  808. X    getting the initial LOCK back so I can patch it, and modifying the
  809. X    submitted packet in the first place are going to prevent me from
  810. X    having an idealized solution for the OPEN request anyway.  All the
  811. X    other requests can be straight patches presumably.
  812. X
  813. X    Ok so now lets test if my initial premise is correct.  I'll do
  814. X    this by patching all requests so my ramdisk justs acts like a debugger
  815. X    peeking into packet transit between two other entities.
  816. X
  817. X    [ YES - the premise appears to be correct; with some qualifications ]
  818. X
  819. X    1) The reason I didn't see any READ's before when I attempted this
  820. X       is because I forgot, I'm supposed to be addressing the VIR device.
  821. X
  822. X    2) There seems to be some kind of general LOCK going on, right away
  823. X
  824. X    3) The LIST and DIRECTORY commands only require 1 access? WHY?
  825. X       This is very important to figure out.  I can't understand why
  826. X       I am not getting an EXNEXT?
  827. X
  828. XLets look at 3
  829. X
  830. X    We get a Packet 8 -> LocateObject
  831. X    It returns a LOCK
  832. X
  833. X    *** Presumably the LOCK has the MESSAGE PORT in it ALSO ***
  834. X
  835. X    Interestingly enough "list" never releases the LOCK it gets
  836. X    (probably bound up with directory stuff...)...Or something like
  837. X    it -> It does act normally if you're not ON the device, but if you
  838. X    are local to it then it *knows* about the lock already available,
  839. X    and simply uses it?
  840. X    (hmmm...actually maybe 'list', 'ls' and 'dir' act the same)
  841. X
  842. X    anyway so if you're on VIR and you do a DIR where all requests are
  843. X    being transfered over to DR1: VIR won't get any packet requests at
  844. X    all -> presumably because the device is LOCKED and the LOCK is
  845. X    cached *and* the lock has a copy of the message port.
  846. X
  847. X    [ yes ] that appears to be correct -> the lock does have the msg port.
  848. X
  849. X    Ok so lets review everything again:
  850. X
  851. X        1) we're going to patch thru all I/O packets by extracting
  852. X           some special info we hide in the FileHandle at OPEN Time
  853. X           (because they call me multiple times).
  854. X
  855. X        2) all directory and lock related stuff we normally just
  856. X           handle ourselves, but if we wanted to patch them through
  857. X           then we would just patch them and forget them...thats all.
  858. X           If somehow somebody doesn't use the LOCK port, but the
  859. X           original PORT (me) then that gets patched also anyway so
  860. X           there is no chance for collision.  If they request a
  861. X           file handle based on incorrect information...well I just
  862. X           return "file not found"...no problems...
  863. X
  864. XSo step 1) is the most important;  Is the earlier scheme the best way?
  865. X
  866. X1    well the I/O can either use my FileHandle with their Port and
  867. X    handle hidden in it -> and if user modifies my handle then I
  868. X    modify theirs in kind
  869. X
  870. X2    Or I stash my info into their FileHandle and hope that they don't
  871. X    trash it.
  872. X
  873. X3    Or I create a Hybrid handle of my own, which stashes their port
  874. X    and handle, as in the first case, but continually re-updates it?
  875. X    Or is this functionally equivilant to case 1?
  876. X
  877. XI suspect the solution is a combination of the above methods...
  878. X
  879. X;----------------------------------------------------------------------------
  880. X
  881. XThe way DOS works:
  882. X
  883. X
  884. XLocate.Object
  885. X    parameters:
  886. X        lock on parent director or NULL (root)
  887. X        name of file
  888. X    comments:
  889. X        presumably there is implicit the parameter of the correct device
  890. X        it requires no parameters other than name in a minimum case,
  891. X        this is why I would refer to it as the "bootstrap" entry gate.
  892. X
  893. XOpen Old File
  894. X    parameters:
  895. X        Lock on its directory (may be zero = root)
  896. X        Name
  897. X    comments:
  898. X        now it fills up your filehandle (passed by reference)
  899. X
  900. X*** lets look at my vir again:
  901. X
  902. X    client submits an "open" request keyed to the VIR subdir LOCK
  903. X    that the file is apparently in.
  904. X
  905. X    i want to now open of another device in another directory,
  906. X    but i have to submit the parent lock apparently;
  907. X
  908. X    i don't see why i can't directly open a file in a sub dir.
  909. X
  910. X    my ACTION_OPEN doesn't support it though (hmmm...I guess the
  911. X    driver doesn't know about the idea of directories).
  912. X
  913. X    (so what do you get if you submit a subdir???...1) either the
  914. X    whole thing is submitted -OR- there are multiple calls to
  915. X    tradverse the layers; check out now please.
  916. X
  917. X    [ the lock was submitted cold - with a parent lock of 0 ]
  918. X
  919. X    ie:
  920. X
  921. X    1> list subdir/mydir/myfile
  922. X        [ resultant issued packet = 8    args:    LOCK,LOCK,MODE ]
  923. X
  924. X    1> list :subdir/mydir/myfile
  925. X        [ resultant issued packet = 8    args:    0,LOCK,MODE ]
  926. X
  927. X    This suggests that at least for the examine function the DEVICE
  928. X    does understand directory structures, (thus making life much
  929. X    easier for me) now lets check READ:
  930. X
  931. X    1> type :subdir/mydir/myfile
  932. X        [ result = packet 1005    args:    FileHandle,0,Name ]
  933. X
  934. X    2> type subdir/mydir/myfile
  935. X        [ result = packet 1005    args:    FileHandle,LOCK,Name ]
  936. X
  937. X    Ok thats great!  So everything works same as before, but i should
  938. X    make sure to clear the lock field of the open file request (although
  939. X    I understand that Matts handler is performing the extra duty, and
  940. X    in fact other handlers might not bother... - To be on the safe
  941. X    side I might want to just steal the ':' LOCK from the DevInfo struct.
  942. X
  943. X    *** but actually I know that I don't have to do that *because* its
  944. X        not Matts handler issuing the quasi-legal request, but other
  945. X        programs...so its quite obvious that a 0 LOCK is supported ***
  946. X
  947. XAre there any ramifications here about locking the device? (so somebody can't
  948. Xremove it from the system on me?)
  949. X
  950. X
  951. Xok so lets cover everything again....
  952. X
  953. X0)    client is browsing around in vir:
  954. X
  955. X1)    all directory handling and renaming is supported right in the handler
  956. X     - acting in its RAMDRIVE way.
  957. X
  958. X2)    the examine command is mostly normal except it does a tiny bit of
  959. X    extra work and returns the indirect file size rather than the ramdrives' file size.
  960. X
  961. X3)    the open_new command we haven't dealt with, or vir to vir copy also.
  962. X
  963. X4)    the open_old figures out and accesses the device (perhaps asking that
  964. X    it be brought online) and gets a file handle on the file.  It
  965. X    retains the device message port, and the device and file lock. the
  966. X    client gets back what appears to be a handle on the actual file.  The
  967. X    open is structured in source in such a way as that it can rely on
  968. X    (as its second) the same routine that the read/write routine relys on.
  969. X
  970. X5)    the read/write commands (yes write is supported even if open_new isnt)
  971. X    pass the requests onto the real device; based on message port info
  972. X    and the proper device lock and file lock.
  973. X
  974. X    in general all modifications to the lock or filehandle are carried
  975. X    through by vir: the ultimate mediator.
  976. X
  977. X6)    learn commands, coalesce, load and save database, turn off the
  978. X    virtual mode of the driver momentarily (process relative to
  979. X    their own operation only) and treat vir: as an ordinary ramdisk.
  980. X
  981. X;-------------------------------------------------------
  982. XJan 23 91
  983. X
  984. X    An alternative to the entire scheme discussed above is the following:
  985. X
  986. X    Intercept the calls to _LVOOpen, _LVORead, _LVOWrite (one level up)
  987. X
  988. X    such that when the system searched for a particular file, it would
  989. X    find it - except that the device would be different.
  990. X
  991. X    I would watch and intercept calls to _LVOOpen accessing "vir:"
  992. X    and remap them over based on my internal database
  993. X
  994. X    perhaps this was the better way...but oh well I'm to far into it now.
  995. X
  996. X;--------------------------------------------------------------------
  997. XFeb 1 91
  998. X
  999. Xok so the vir: device is working now, we can do the following:
  1000. X
  1001. X        - learn new files (should csum each key, assign media #'s)
  1002. X        - virtually access files (should lock subdir if name >128)
  1003. X
  1004. X    now we need to deal with:
  1005. X
  1006. X        - coalesce intelligently  (or just find duplicates)
  1007. X        - writing new files to vir:
  1008. X
  1009. XNEW FILES:
  1010. X        just write to dh0: with a datestamp unique name.
  1011. X        (or just write to VIR: as a non-virtual file)
  1012. X
  1013. XCOALESCE
  1014. X        - accept wildcard source, wildcard dest
  1015. X        - compare all sources to all dests
  1016. X        - retag dests (copy one to the other) or just print dup addrs
  1017. X
  1018. X;---------------------------------------------------------
  1019. Xmarch 2 1991
  1020. X    tidied up vir: a bit, more robust
  1021. X    determined that the FIB_PADDING or FIB_RESERVED is really and
  1022. X    truly RESERVED unfortunately....I'm currently using the comment
  1023. X    field, but I'll have to think more about it.
  1024. X
  1025. X    wrote a coalesce based on 'du' from Stuart Mitchell
  1026. X
  1027. X    now trying to make coalesce be smart about its directory
  1028. X    comparison...not every compare the same file twice
  1029. X    and do so implicitly - by copying the anchor chain, and
  1030. X    searching next file on as a comparator...not all files again..
  1031. X
  1032. X    ...wait! i can't do that...cause src and dest are not
  1033. X    neccessarily the same...i guess i could have an optimized mode
  1034. X    (anyway i couldn't get it to work so....)
  1035. X
  1036. X
  1037. END_OF_FILE
  1038. if test 32366 -ne `wc -c <'virt_mine.doc'`; then
  1039.     echo shar: \"'virt_mine.doc'\" unpacked with wrong size!
  1040. fi
  1041. # end of 'virt_mine.doc'
  1042. fi
  1043. echo shar: End of archive 3 \(of 4\).
  1044. cp /dev/null ark3isdone
  1045. MISSING=""
  1046. for I in 1 2 3 4 ; do
  1047.     if test ! -f ark${I}isdone ; then
  1048.     MISSING="${MISSING} ${I}"
  1049.     fi
  1050. done
  1051. if test "${MISSING}" = "" ; then
  1052.     echo You have unpacked all 4 archives.
  1053.     rm -f ark[1-9]isdone
  1054. else
  1055.     echo You still need to unpack the following archives:
  1056.     echo "        " ${MISSING}
  1057. fi
  1058. ##  End of shell archive.
  1059. exit 0
  1060. -- 
  1061. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  1062. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  1063. Post requests for sources, and general discussion to comp.sys.amiga.misc.
  1064.